<?php
/**
 * ****************************
 * *** Web Archive DePacker ***
 * ****************************
 *
 * The WADP was developed to reduce the time-deficit deploying web-applications
 * with a huge number of files by ftp. In fact it can be used to depack zip archives
 * for any purpose.
 *
 * functionality:
 * - list archives in current directory
 * - show archives content
 * - extract zip-archives (entirely, or part of it)
 *
 * requirements:
 * - php5.2 or higher (with zlib)
 * 
 * make sure that this script runs with php5.2 or higher. if you you are on a shared
 * hosting platform ask your hoster if there are multiple php version installed.
 * you may use them by changing the handler php files by using .htaccess
 *
 * ****************************
 *
 * @author Claude Gex
 * @since 10.05.2008
 * @version 0.1.2
 *
 */

/* some resources like images, and js */
$bg = '/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAASwAA/+4AJkFkb2JlAGTAAAAAAQMA
FQQDBgoNAAAB6AAAAgkAAAKJAAADQf/bAIQAAwICAgICAwICAwUDAwMFBQQDAwQFBgUFBQUFBggG
BwcHBwYICAkKCgoJCAwMDAwMDA4ODg4OEBAQEBAQEBAQEAEDBAQGBgYMCAgMEg4MDhIUEBAQEBQR
EBAQEBARERAQEBAQEBEQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQ/8IAEQgAOgA+AwERAAIR
AQMRAf/EAIgAAQEBAQEAAAAAAAAAAAAAAAIBAAMIAQEBAQEBAAAAAAAAAAAAAAAAAgEDBRAAAgMB
AAAAAAAAAAAAAAAAMGAQUBEBEQEAAAAAAAAAAAAAAAAAAABgEgEAAAAAAAAAAAAAAAAAAABgEwEA
AwEBAQACAgMAAAAAAAABABARMSFBIMEwYFBhgf/aAAwDAQACEQMRAAAB9E+LydsCF0qTBk7YELpU
mDK6VBC6VJgyVLoQulSYMlS6mJhUmDJUujI46WmDJUujKYVMGSpdGUwqXQjNuumOcFpUx//aAAgB
AQABBQI+UGG5P//aAAgBAgABBQJA/9oACAEDAAEFAkD/2gAIAQICBj8CAf/aAAgBAwIGPwIB/9oA
CAEBAQY/AgH/2gAIAQEDAT8hDaXIuwK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ucyB9OwoKICAgIHZhciB0ID0gRWxlbWVudC5faW5zZXJ0aW9uVHJhbnNs
YXRpb25zLCBjb250ZW50LCBwb3NpdGlvbiwgcG9zLCB0YWdOYW1lOwoKICAgIGZvciAocG9zaXRp
b24gaW4gaW5zZXJ0aW9ucykgewogICAgICBjb250ZW50ICA9IGluc2VydGlvbnNbcG9zaXRpb25d
OwogICAgICBwb3NpdGlvbiA9IHBvc2l0aW9uLnRvTG93ZXJDYXNlKCk7CiAgICAgIHBvcyAgICAg
ID0gdFtwb3NpdGlvbl07CgogICAgICBpZiAoY29udGVudCAmJiBjb250ZW50LnRvRWxlbWVudCkg
Y29udGVudCA9IGNvbnRlbnQudG9FbGVtZW50KCk7CiAgICAgIGlmIChPYmplY3QuaXNFbGVtZW50
KGNvbnRlbnQpKSB7CiAgICAgICAgcG9zLmluc2VydChlbGVtZW50LCBjb250ZW50KTsKICAgICAg
ICBjb250aW51ZTsKICAgICAgfQoKICAgICAgY29udGVudCA9IE9iamVjdC50b0hUTUwoY29udGVu
dCk7CiAgICAgIHRhZ05hbWUgPSAoKHBvc2l0aW9uID09ICdiZWZvcmUnIHx8IHBvc2l0aW9uID09
ICdhZnRlcicpCiAgICAgICAgPyBlbGVtZW50LnBhcmVudE5vZGUgOiBlbGVtZW50KS50YWdOYW1l
LnRvVXBwZXJDYXNlKCk7CgogICAgICBpZiAodC50YWdzW3RhZ05hbWVdKSB7CiAgICAgICAgdmFy
IGZyYWdtZW50cyA9IEVsZW1lbnQuX2dldENvbnRlbnRGcm9tQW5vbnltb3VzRWxlbWVudCh0YWdO
YW1lLCBjb250ZW50LnN0cmlwU2NyaXB0cygpKTsKICAgICAgICBpZiAocG9zaXRpb24gPT0gJ3Rv
cCcgfHwgcG9zaXRpb24gPT0gJ2FmdGVyJykgZnJhZ21lbnRzLnJldmVyc2UoKTsKICAgICAgICBm
cmFnbWVudHMuZWFjaChwb3MuaW5zZXJ0LmN1cnJ5KGVsZW1lbnQpKTsKICAgICAgfQog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jezN9J10iLAogICAgICAnXj0nOiAiW3N0YXJ0cy13aXRo
KEAjezF9LCAnI3szfScpXSIsCiAgICAgICckPSc6ICJbc3Vic3RyaW5nKEAjezF9LCAoc3RyaW5n
LWxlbmd0aChAI3sxfSkgLSBzdHJpbmctbGVuZ3RoKCcjezN9JykgKyAxKSk9JyN7M30nXSIsCiAg
ICAgICcqPSc6ICJbY29udGFpbnMoQCN7MX0sICcjezN9JyldIiwKICAgICAgJ349JzogIltjb250
YWlucyhjb25jYXQoJyAnLCBAI3sxfSwgJyAnKSwgJyAjezN9ICcpXSIsCiAgICAgICd8PSc6ICJb
Y29udGFpbnMoY29uY2F0KCctJywgQCN7MX0sICctJyksICctI3szfS0nKV0iCiAgICB9LAogICAg
cHNldWRvczogewogICAgICAnZmlyc3QtY2hpbGQnOiAnW25vdChwcmVjZWRpbmctc2libGluZzo6
KildJywKICAgICAgJ2xhc3QtY2hpbGQnOiAgJ1tub3QoZm9sbG93aW5nLXNpYmxpbmc6OiopXScs
CiAgICAgICdvbmx5LWNoaWxkJzogICdbbm90KHByZWNlZGluZy1zaWJsaW5nOjoqIG9yIGZvbGxv
d2luZy1zaWJsaW5nOjoqKV0nLAogICAgICAnZW1wdHknOiAgICAgICAiW2NvdW50KCopID0gMCBh
bmQgKGNvdW50KHRleHQoKSkgPSAwIG9yIHRyYW5zbGF0ZSh0ZXh0KCksICcgXHRcclxuJywgJycp
ID0gJycpXSIsCiAgICAgICdjaGVja2VkJzogICAgICJbQGNoZWNrZWRdIiwKICAgICAgJ2Rpc2Fi
bGVkJzogICAgIltAZGlzYWJsZWRdIiwKICAgICAgJ2VuYWJsZWQnOiAgICAgIltub3QoQGRpc2Fi
bGVkKV0iLAogICAgICAnbm90JzogZnVuY3Rpb24obSkgewogICAgICAgIHZhciBlID0gbVs2XSwg
cCA9IFNlbGVjdG9yLnBhdHRlcm5zLAogICAgICAgICAgICB4ID0gU2VsZWN0b3IueHBhdGgsIGxl
LCBtLCB2OwoKICAgICAgICB2YXIgZXhjbHVzaW9uID0gW107CiAgICAgICAgd2hpbGUgKGUgJiYg
bGUgIT0gZSAmJiAoL1xTLykudGVzdChlKSkgewogICAgICAgICAgbGUgPSBlOwogICAgICAgICAg
Zm9yICh2YXIgaSBpbiBwKSB7CiAgICAgICAgICAgIGlmIChtID0gZS5tYXRjaChwW2ldKSkgewog
ICAgICAgICAgICAgIHYgPSBPYmplY3QuaXNGdW5jdGlvbih4W2ldKSA/IHhbaV0obSkgOiBuZXcg
VGVtcGxhdGUoeFtpXSkuZXZhbHVhdGUobSk7CiAgICAgICAgICAgICAgZXhjbHVzaW9uLnB1c2go
IigiICsgdi5zdWJzdHJpbmcoMSwgdi5sZW5ndGggLSAxKSArICIpIik7CiAgICAgICAgICAgICAg
ZSA9IGUucmVwbGFjZShtWzBdLCAnJyk7CiAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAg
IH0KICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgcmV0dXJuICJbbm90KCIgKyBleGNsdXNp
b24uam9pbigiIGFuZCAiKSArICIpXSI7CiAgICAgIH0sCiAgICAgICdudGgtY2hpbGQnOiAgICAg
IGZ1bmN0aW9uKG0pIHsKICAgICAgICByZXR1cm4gU2VsZWN0b3IueHBhdGgucHNldWRvcy5udGgo
Iihjb3VudCguL3ByZWNlZGluZy1zaWJsaW5nOjoqKSArIDEpICIsIG0pOwogICAgICB9LAogICAg
ICAnbnRoLWxhc3QtY2hpbGQnOiBmdW5jdGlvbihtKSB7CiAgICAgICAgcmV0dXJuIFNlbGVjdG9y
LnhwYXRoLnBzZXVkb3MubnRoKCIoY291bnQoLi9mb2xsb3dpbmctc2libGluZzo6KikgKyAxKSAi
LCBtKTsKICAgICAgfSwKICAgICAgJ250aC1vZi10eXBlJzogICAgZnVuY3Rpb24obSkgewogICAg
ICAgIHJldHVybiBTZWxlY3Rvci54cGF0aC5wc2V1ZG9zLm50aCgicG9zaXRpb24oKSAiLCBtKTsK
ICAgICAgfSwKIC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TsKICAgICAgICAgIH0gZWxzZSBpZiAoY29tYmluYXRvciA9PSAnZGVzY2Vu
ZGFudCcpIHsKICAgICAgICAgICAgZm9yICh2YXIgaSA9IDAsIG5vZGU7IG5vZGUgPSBub2Rlc1tp
XTsgaSsrKQogICAgICAgICAgICAgIGlmIChFbGVtZW50LmRlc2NlbmRhbnRPZih0YXJnZXROb2Rl
LCBub2RlKSkgcmV0dXJuIFt0YXJnZXROb2RlXTsKICAgICAgICAgIH0gZWxzZSBpZiAoY29tYmlu
YXRvciA9PSAnYWRqYWNlbnQnKSB7CiAgICAgICAgICAgIGZvciAodmFyIGkgPSAwLCBub2RlOyBu
b2RlID0gbm9kZXNbaV07IGkrKykKICAgICAgICAgICAgICBpZiAoU2VsZWN0b3IuaGFuZGxlcnMu
cHJldmlvdXNFbGVtZW50U2libGluZyh0YXJnZXROb2RlKSA9PSBub2RlKQogICAgICAgICAgICAg
ICAgcmV0dXJuIFt0YXJnZXROb2RlXTsKICAgICAgICAgIH0gZWxzZSBub2RlcyA9IGhbY29tYmlu
YXRvcl0obm9kZXMpOwogICAgICAgIH0KICAgICAgICBmb3IgKHZhciBpID0gMCwgbm9kZTsgbm9k
ZSA9IG5vZGVzW2ldOyBpKyspCiAgICAgICAgICBpZiAobm9kZSA9PSB0YXJnZXROb2RlKSByZXR1
cm4gW3RhcmdldE5vZGVdOwogICAgICAgIHJldHVybiBbXTsKICAgICAgfQogICAgICByZXR1cm4g
KHRhcmdldE5vZGUgJiYgRWxlbWVudC5kZXNjZW5kYW50T2YodGFyZ2V0Tm9kZSwgcm9vdCkpID8g
W3RhcmdldE5vZGVdIDogW107CiAgICB9LAoKICAgIGNsYXNzTmFtZTogZnVuY3Rpb24obm9kZXMs
IHJvb3QsIGNsYXNzTmFtZSwgY29tYmluYXRvcikgewogICAgICBpZiAobm9kZXMgJiYgY29tYmlu
YXRvcikgbm9kZXMgPSB0aGlzW2NvbWJpbmF0b3JdKG5vZGVzKTsKICAgICAgcmV0dXJuIF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dW5jdGlvbihpdGVy
YXRvcikgewogICAgdGhpcy5lbGVtZW50LmNsYXNzTmFtZS5zcGxpdCgvXHMrLykuc2VsZWN0KGZ1
bmN0aW9uKG5hbWUpIHsKICAgICAgcmV0dXJuIG5hbWUubGVuZ3RoID4gMDsKICAgIH0pLl9lYWNo
KGl0ZXJhdG9yKTsKICB9LAoKICBzZXQ6IGZ1bmN0aW9uKGNsYXNzTmFtZSkgewogICAgdGhpcy5l
bGVtZW50LmNsYXNzTmFtZSA9IGNsYXNzTmFtZTsKICB9LAoKICBhZGQ6IGZ1bmN0aW9uKGNsYXNz
TmFtZVRvQWRkKSB7CiAgICBpZiAodGhpcy5pbmNsdWRlKGNsYXNzTmFtZVRvQWRkKSkgcmV0dXJu
OwogICAgdGhpcy5zZXQoJEEodGhpcykuY29uY2F0KGNsYXNzTmFtZVRvQWRkKS5qb2luKCcgJykp
OwogIH0sCgogIHJlbW92ZTogZnVuY3Rpb24oY2xhc3NOYW1lVG9SZW1vdmUpIHsKICAgIGlmICgh
dGhpcy5pbmNsdWRlKGNsYXNzTmFtZVRvUmVtb3ZlKSkgcmV0dXJuOwogICAgdGhpcy5zZXQoJEEo
dGhpcykud2l0aG91dChjbGFzc05hbWVUb1JlbW92ZSkuam9pbignICcpKTsKICB9LAoKICB0b1N0
cmluZzogZnVuY3Rpb24oKSB7CiAgICByZXR1cm4gJEEodGhpcykuam9pbignICcpOwogIH0KfTsK
Ck9iamVjdC5leHRlbmQoRWxlbWVudC5DbGFzc05hbWVzLnByb3RvdHlwZSwgRW51bWVyYWJsZSk7
CgovKi0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tKi8KCkVsZW1lbnQuYWRkTWV0aG9kcygpOw==
';

$res = array('bg' => array('content-type' => 'image/jpeg', 'content' => &$bg),
             'corner' => array('content-type' => 'image/gif', 'content' => &$corner),
             'lightCorner' => array('content-type' => 'image/jpeg', 'content' => &$lightCorner),
             'prototype' => array('content-type' => 'text/javascript', 'content' => &$prototype),
             'spacer' => array('content-type' => 'image/gif', 'content' => &$spacer),
             'underline1' => array('content-type' => 'image/gif', 'content' => &$underline1),
             'underline2' => array('content-type' => 'image/gif', 'content' => &$underline2),
             'loading' => array('content-type' => 'image/gif', 'content' => &$loading));

// check if a resource is requested
if(isset($_GET['res']) && array_key_exists($_GET['res'], $res)) {
	$resource = $res[$_GET['res']];
	// resource requested... set the content-type
	header('Content-Type: ' . $resource['content-type']);
	echo base64_decode($resource['content']);

	// ensure output is sent
	flush();
	// exit further execution
	exit();
}
/* RESOURCE PART END */

// define dimension-units
$sizeExt = array('B','KB','MB','GB');

// set the accepted archive extensions
$acceptedArchives = array('.zip'); // NOTE: later the wadp could get the ability to unpack .gz, .tar, bz2 and so on...

// determine the current directory
define('DIR', substr($_SERVER["SCRIPT_FILENAME"],0,strrpos($_SERVER["SCRIPT_FILENAME"],"/")));

// sets the extension pattern
{
	// start
	$pattern = '/^.*(';

	// counter used for pipe decisions
	$extCount = 0;

	// get all extension from acceptedArchives and build an expression
	foreach($acceptedArchives as $key) {
		if($extCount++ > 0 && ($extCount-1) < count($acceptedArchives))
		$pattern .= '|'; // pipe needed
		$pattern .= str_replace('.','\\.',$key); // beware the expression of the hungry '.'
	}

	// finish expression
	$pattern .= ')$/';
}

// TODO add ability to precheck if ZipArchive is ok

/**
 * @param filesize
 * @return output formatted filesize
 */
function calculateFileSize($filesize) {
	global $sizeExt;

	// declare var's
	$count = 0;
	$returnVal = '';

	// copy filesize to work with
	$size = $filesize;

	// loop as long as we should take a bigger dimension-unit
	while($size > 1024) {
		$size = $size / 1024;

		// increments counter to determine which dimension-unit should be used for output
		$count++;
	}

	// returns the calucalated and formatted archive-size
	return round($size,1) . " " . $sizeExt[$count];
}

/**
 * returns an array - used by ajax call
 *
 * @param unknown_type $archive
 * @return unknown
 */
function getArchiveInfo($archive) {
	$zip = new ZipArchive();
	$zip->open($archive);
	
	$arr = array();
	for ($i=0; $i<$zip->numFiles;$i++) {
		$info = array();
		foreach($zip->statIndex($i) as $key => $value) {
			$val = $value;
			if($key == "size") {
				$val = calculateFileSize($val);
			}
			if($key == "name") {
				if(strrpos($val,'/') == strlen($val)-1) {
					$val = substr($val,0,strlen($val) -1);
				}
			}
			$info[$key] = $val;
			$info['archivename'] = $archive;
		}
		array_push($arr, $info);
	}
	$zip->close();
	return $arr;
}

/**
 * Returns some information about an entry within the archive
 *
 * @param String $archive The archive's filename
 * @param String $filename The filename of a packaged file
 */
function getFileInfo($archive,$filename) {
	$zip = new ZipArchive();
	$res = $zip->open($archive);
	
	$attributes = array();
	if ($res === TRUE) {
	    $attributes = $zip->statName($filename);
	    $zip->close();
	} else {
		return 'Zip Archive ' . $filename . ' could not be opened. ';
	}
	$attributes['size'] = calculateFileSize($attributes['size']);
	return $attributes;
}

/**
 * @return directory array
 */
function listDirectory($archivesOnly) {
	global $pattern;

	// initialize an array
	$arr = array();

	// get a handle
	$dh = @opendir(DIR);
	if($dh) {
		// iterate over the directory content
		while (($file = @readdir($dh)) !== false) {
			// neither follow virtual links nor directories
			if($file == "." || $file =="..") {
				continue;
			}
			
			if($archivesOnly == "true") {
				preg_match($pattern,$file,$match);
				if(empty($match) || $match[0] == "") {
					continue;
				}
			}
			
			// don't return size in case of directories
			$size = calculateFileSize(filesize($file));
			if(!is_file($file)) {
				$size = '';
			}
			
			// build the return array
			array_push($arr,array('name' => $file, 'size' => $size));
		}
	} else {
		return 'Current Directory could not be opened. Reason: ' . $dh;
	}

	return $arr;
}

/**
 * Used for extracting archives
 *
 * @param String $archive
 * @param String $singleFile
 * @return String 'true' -> if ok, 'false' if there has been an error
 */
function extractArchive($archive,$singleFile) {
	global $acceptedArchives;
	global $pattern;
	$ret = 'false';
	if(isset($archive) && file_exists($archive) && strpos($archive,'./../') == false && strpos($archive,'../') == false) {
		// takes information from the filename with regex
		preg_match($pattern,$archive,$match);
	
		// check if this extension has a mapping-entry
		if(in_array($match[1],$acceptedArchives)) { // check on archive-extension
			$zip = new ZipArchive;
			if ($zip->open($archive) === TRUE) {
				if(trim($singleFile) != null) {
				    $zip->extractTo(DIR, $singleFile);
				} else {
					$zip->extractTo(DIR);
				}
			    $zip->close();
			    $ret = 'true';
			}
		}
	}
	return $ret;
}

/**
 * Helper function. Encodes the passed value to JSON
 * puts out the JSON-String with the correct mime-type 
 *
 * @param $responseValue
 */
function ajaxResponse($responseValue) {
	header('Content-Type: application/json');
	echo json_encode($responseValue);
	flush();
	exit();
}
// handle ajax calls
if(isset($_GET['getArchiveInfo'])) {
	ajaxResponse(getArchiveInfo($_GET['getArchiveInfo']));
} elseif(isset($_GET['listDir'])) {
	ajaxResponse(listDirectory($_GET['listDir']));
} elseif(isset($_GET['extract'])) {
	ajaxResponse(extractArchive($_GET['extract'], $_GET['singleFile']));
} elseif(isset($_GET['getFileInfo']) && isset($_GET['archive'])) {
	ajaxResponse(getFileInfo($_GET['archive'], $_GET['getFileInfo']));
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
Design by Free CSS Templates
http://www.freecsstemplates.org
Released for free under a Creative Commons Attribution 2.5 License

Name       : Altruism
Description: A two-column, fixed-width template fit for 1024x768 screen resolutions.
Version    : 1.0
Released   : 20080308

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>Web Archive DePacker</title>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<style type="text/css">
	/*
	Design by Free CSS Templates
	http://www.freecsstemplates.org
	Released for free under a Creative Commons Attribution 2.5 License
	*/
	* { margin: 0;padding: 0; }
	body { margin: 0; padding: 0; background: #E1F0C4 url(<?php echo $_SERVER['PHP_SELF']; ?>?res=bg) repeat; text-align: justify; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 11px; color: #909B78; }
	h1,h2,h3 { margin-top: 1.5em; }
	h1 { font-size: 2em; }
	h2 { font-size: 1.4em; }
	h3 { font-size: 1em; }
	p,ul,ol { margin-top: 1.5em; }
	a { color: #909B78; }
	a:hover { text-decoration: none; }
	ul,ol { margin-left: 3em; }
	blockquote { margin-left: 3em; margin-right: 3em; }
	hr { display: none; }
	.hr1 { height: 4px; padding-bottom: 20px; background: url(<?php echo $_SERVER['PHP_SELF']; ?>?res=underline1) repeat-x left top; }
	
	/* Header */
	#header { width: 900px; height: 150px; margin: 0 auto; background: #FFFFFF; }
	
	/* Logo */
	#logo { float: left; margin: 0; padding: 0; width: 504px; height: 150px; }
	#logo h1,#logo h2 { margin: 0; padding: 0; font-family: Georgia, "Times New Roman", Times, serif; }
	#logo h1 { margin: 0; padding: 0; padding: 70px 0 0 50px; font-size: 40px; font-weight: normal; color: #616B4F; }
	#logo h1 a { color: #616B4F; }
	#logo h2 { margin: 0; padding: 0; padding-left: 50px; text-transform: uppercase; font-size: 14px; color: #C6D0B3; }
	#logo h2 a { color: #C6D0B3; }
	#logo a { text-decoration: none; }
	
	/* Menu */
	#menu { margin: 0; padding-top: 70px; float: right; width: 396px; }
	#menu ul { margin: 0; list-style: none; }
	#menu li { display: inline; }
	#menu a, span { display: block;  float: left; margin: 0;  padding: 10px 10px; text-align: center; text-decoration: none; text-transform: uppercase; font-size: 14px; font-weight: normal; font-family: Georgia, "Times New Roman", Times, serif; color: #616B4F; }
	#menu a { text-decoration: underline; }
	#menu a:hover, #menu  a.active { background: #9FAB87; color: #FFFFFF; }
	#menu .current_page_item a { background: #9FAB87; color: #FFFFFF; }
	
	/* Page */
	#page { width: 800px; margin: 0 auto; padding: 0px 50px 0px 50px; background: #FFFFFF; }
	#latest-content { float: left; width: 100%; padding: 46px 0px 0px 0px; background: url(<?php echo $_SERVER['PHP_SELF']; ?>?res=underline1) repeat-x left top; line-height: 25px; }
	#latest-content h1 { letter-spacing: -.5px; font-family: Georgia, "Times New Roman", Times, serif; font-size: 26px; font-weight: normal; color: #616B4F; }
	.content .title { margin: 0; }
	.content h2 { letter-spacing: -.5px; font-family: Georgia, "Times New Roman", Times, serif; font-size: 26px; font-weight: normal; color: #616B4F; }
	.content .meta { height: 31px; background: #EAF0DE url(<?php echo $_SERVER['PHP_SELF']; ?>?res=lightCorner) no-repeat right bottom; text-decoration: none; }
	.content .posted { float: left; height: 16px; padding: 5px 20px 5px 12px; }
	.content .permalink,.content .comments { float: right; height: 16px; }
	.content .entry { margin-bottom: 10px; padding-bottom: 35px; }
	.content table { width: 800px; line-height: 15px; }
	.content table tr.active { background-color: #e3f2cb; }
	.content table tr.fileListEntry:hover { background-color: #e3f2cb; }
	.content td { padding: 5px; }
	.content thead td { background-color: #96a96f; color: #ffffff; }
	.content table.fileInfo { width: 740px; margin-left: 30px;background: #96A96F url(<?php echo $_SERVER['PHP_SELF']; ?>?res=corner) no-repeat right bottom; padding: 10px 20px 0px 20px; color: #DFE6D1; }
	#recent-content { float: right; width: 250px; padding: 0px 0px 30px 0px; }
	#recent-content .entry { background: #96A96F url(<?php echo $_SERVER['PHP_SELF']; ?>?res=corner) no-repeat right bottom; padding: 0px 19px 30px 19px; }
	#recent-content .entry h2 { margin: 0; padding: 0px 19px 0px 0px; background: url(<?php echo $_SERVER['PHP_SELF']; ?>?res=underline2) repeat-x left bottom; text-transform: uppercase; font-family: Georgia, "Times New Roman", Times, serif; font-size: 1.4em; color: #FFFFFF; }
	
	/* Sidebar */
	#sidebar { clear: both; background: #96A96F url(<?php echo $_SERVER['PHP_SELF']; ?>?res=corner) no-repeat right bottom; padding: 10px 20px 0px 20px; color: #DFE6D1; }
	#sidebar ul { margin: 0; padding: 0; list-style: none; }
	#sidebar li { display: block; float: left; width: 660px; padding: 15px; }
	#sidebar li ul { line-height: 1.8em; margin: 0px; }
	#sidebar li li { width: 220x; display: list-item; float: none;  padding: 0; }
	#sidebar h2,.content table h2 {  width: 220x;  margin: 0 0 15px 0; padding: 0 50px 10px 0; background: url(<?php echo $_SERVER['PHP_SELF']; ?>?res=underline2) repeat-x left bottom;text-transform: uppercase; font-family: Georgia, "Times New Roman", Times, serif; color: #FFFFFF; }
	.content table h2 { font-size: 1.4em; margin: 0px; }
	#sidebar p { color: #DFE6D1; }
	#sidebar a,.content table a { text-decoration: underline; color: #F1F6E8;}
	#sidebar a:hover { text-decoration: none; }
	
	/* Sidebar1 */ /* Sidebar */
	#sidebar1 { float: right; width: 250px; }
	#sidebar1 ul { margin: 0; padding: 0;  list-style: none; }
	#sidebar1 li { background: #96A96F; }
	#sidebar1 li ul { line-height: 25px; padding: 0px 20px 30px 20px;background: #96A96F url(<?php echo $_SERVER['PHP_SELF']; ?>?res=corner) no-repeat right bottom; margin-bottom: 40px; }
	#sidebar1 ul li table { line-height: 25px; margin: 0px 20px 40px 20px; }
	#sidebar1 td { background: #96A96F; color: #DFE6D1; }
	#sidebar1 li li { padding: 0; background: #96A96F;  color: #DFE6D1; }
	#sidebar1 h2 { width: 190px; margin: 0 0 15px 20px; padding: 20px 0 7px 0; background: url(<?php echo $_SERVER['PHP_SELF']; ?>?res=underline2) repeat-x left bottom; text-transform: uppercase; font-family: Georgia, "Times New Roman", Times, serif; color: #FFFFFF; }
	#sidebar1 a { color: #FFFFFF; }
	
	/* Footer */
	#footer { width: 800px; height: 50px; margin: 0 auto; padding: 0 50px 0 50px; background: #FFFFFF; }
	#footer p { margin: 0; padding: 15px; text-align: center; font-size: 11px; color: #909B78;  }
	#footer a { color: #909B78; }
	
	/* Progress */
	.progress { padding-left: 160px; }
	</style>
	<script type="text/javascript" src="<?php echo $_SERVER['PHP_SELF']; ?>?res=prototype"></script>
	<script type="text/javascript">
	var activeArchive = ''; // current activeArchives filename
	var activeArchiveObject = null; // object, contains archives index, when fetched before
	var extractedFile=''; // if only a single file has been extracted, the filename goes here
	var extracted = false; // indicates if there was an extraction progress
	// some utility functions which simplifies table creation
	function addTableHead(table){
		var head = document.createElement('thead');
		Element.extend(head);// without this line, 
		// the next line causes IE to stop processing the script!
		table.appendChild(head);
		return head;
	}
	function addTableBody(table){
		var body = document.createElement('tbody');
		Element.extend(body);// without this line, 
		// the next line causes IE to stop processing the script!
		table.appendChild(body);
		return body;
	}
	function addRow(element){
		var row = document.createElement('tr');
		Element.extend(row);// without this line, 
		// the next line causes IE to stop processing the script!
		element.appendChild(row);
		return row
	}
	function addCell(row, value){
		var cell = document.createElement('td');
		Element.extend(cell);// without this line, 
		// the next line causes IE to stop processing the script!
		cell.innerHTML = value;
		row.appendChild(cell);
		return cell;
	}
	function addLink(cell, href, text){
		var a = document.createElement('a');
		Element.extend(a);// without this line, 
		// the next line causes IE to stop processing the script!
		a.innerHTML = text;
		a.href = href;
		cell.appendChild(a);
		return a;
	}
	// pass a row element, and and an array of string
	// this function adds as many cols to the row as strings 
	// are in the passed cols array
	function buildHeadCells(row, cols){
		for (i = 0; i < cols.length; i++) {
			var cell = addCell(row, '');
			
			var h2 = document.createElement('h2'); // we use h2
			Element.extend(h2);// without this line, 
			// the next line causes IE to stop processing the script!
			h2.innerHTML = cols[i];
			cell.appendChild(h2);
		}
	}
	
	// remove all active marks, and call resetArchive
	function reset(){
		$$('.fileInfo').each(function(elem, index){
			// we were on table level, but we want to remove the entire row,
			// so go up through cell and row
			elem.parentNode.parentNode.remove();
		});
		$$('tr.active').each(function(elem, index){
			elem.removeClassName('active');
		});
		resetArchive();
	}
	// reset the global variables
	function resetArchive() {
		activeArchiveObject=null;
		activeArchive='';
		extractedFile='';
		extracted=false;
	}
	
	// show only archvies
	function showArchives(){
		$('title').innerHTML = 'Archives';
		listDir($('fileListing'), true);
		$('tabArchive').addClassName('active');
		if($('tabAll').hasClassName('active')) {
			$('tabAll').removeClassName('active');
		}
	}
	
	// show all files
	function showAll(){
		$('title').innerHTML = 'All Files';
		listDir($('fileListing'), false);
		$('tabAll').addClassName('active');
		if($('tabArchive').hasClassName('active')) {
			$('tabArchive').removeClassName('active');
		}
	}
	
	// creates ajax call to fetch directory entries and puts the result into the DOM
	function listDir(elem, archivesOnly){
		showProgress();
		new Ajax.Request('<?php echo $_SERVER['PHP_SELF']; ?>?listDir=' + archivesOnly, {
			method: 'get',
			onSuccess: function(transport){
			
				var response = transport.responseText || "no response text";
				var data = null;
				try {
					data = response.evalJSON();
				} catch (e) {
					addConsoleMsg(response);
					hideProgress();
					return; // don't go any step further
				}
				
				var table = document.createElement('table');
				Element.extend(table);// without this line, 
				// the next line causes IE to stop processing the script!
				table.writeAttribute('cellspacing', '0px');
				table.writeAttribute('id', 'result');
				
				// remove if present, otherwise, don't care about
				try {
					$('result').remove();
				} catch (ex) {}
				elem.appendChild(table);
				
				var head = addTableHead(table);
				var body = addTableBody(table);
				var headRow = addRow(head);
				
				buildHeadCells(headRow, new Array('Archivename', 'Size'));
				
				// iterate over each line (=file/directory)
				for (i = 0; i < data.length; i++) {
					var row = addRow(body);
					
					// if there was an extract action before, we might want to highlight something
					if(extracted) {
						// multiple extraction
						for (j = 0; activeArchiveObject != null && extractedFile == '' && j < activeArchiveObject.length; j++) {
							if(activeArchiveObject[j].name==data[i].name) {
								row.addClassName('active');
							}
						}
						// single extraction
						if(data[i].name == extractedFile) {
							row.addClassName('active');
						}
					}
					
					row.addClassName('fileListEntry');
					addCell(row, data[i].name);
					addCell(row, data[i].size);
					
					// do only show archives info on click, when there are only archives in the list
					if (archivesOnly) {
						row.observe('click', getArchiveInfo);
					}
				}
				resetArchive();
				extracted = false;
				hideProgress();
			},
			onFailure: function(){
				addConsoleMsg('Ajax error on listDir');
				hideProgress();
			}
		});
	}
	
	// get information about the archive, in fact, the index is built
	function getArchiveInfo(event) {
		reset();
		showProgress();
		
		var source = event.element();
		var parent = source.parentNode;
		parent.addClassName('active');
		
		var parentTable = parent.parentNode;
		activeArchive = parent.firstChild.innerHTML;
		
		new Ajax.Request('<?php echo $_SERVER['PHP_SELF']; ?>?getArchiveInfo=' + activeArchive, {
			method: 'get',
			onSuccess: function(transport){
				var response = transport.responseText || "no response text";
				var data = null;
				try {
					data = response.evalJSON();
				} catch (e) {
					addConsoleMsg(response);
					hideProgress();
					return; // don't go any step further
				}
				activeArchiveObject = data;
				
				var table = document.createElement('table');
				Element.extend(table);// without this line, 
				// the next line causes IE to stop processing the script!
				table.writeAttribute('cellspacing', '0');
				table.addClassName('fileInfo');
				
				var head = addTableHead(table);
				var body = addTableBody(table);

				var row = addRow(head);
				addCell(row, '');
				addCell(row, '');
				addLink(addCell(row, '').writeAttribute('style','text-align:right'), "javascript:reset()", 'Close');

				var headRow = addRow(head);				
				buildHeadCells(headRow, new Array('Name', 'Size', 'Extract'));
				
				// a row giving the opportunity to extract all files
				var rowAll = addRow(body);
				addCell(rowAll, '');
				addCell(rowAll, '');
				addLink(addCell(rowAll, ''), "javascript:extract('" + activeArchive + "','')", 'Extract All');
				
				
				// show archive's entries
				for (i = 0; i < data.length; i++) {
					var row = addRow(body);
					addCell(row, data[i].name);
					addCell(row, data[i].size);
					var cell = addCell(row, '');
					// add link for extraction action
					addLink(cell, "javascript:extract('" + activeArchive + "','" + data[i].name + "')", "Extract");
				}
				
				// add spacer row
				addCell(addRow(body),'<h2>&nbsp;<\/h2>').writeAttribute('colspan','3');
				
				// add summary row
				var summary = addRow(body);
				addCell(summary, 'Number of Files: ' + data.length);
				addCell(summary, '');
				addLink(addCell(summary, ''), "javascript:extract('" + activeArchive + "','')", 'Extract All');

				// wrap the table into a row/cell, and insert it after the selected row
				var r = document.createElement('tr');
				Element.extend(r);// without this line, 
				// the next line causes IE to stop processing the script!
				var c = addCell(r, '');
				c.writeAttribute('colspan', '2');
				c.appendChild(table);
				parent.insert({after: r});
				hideProgress();
			},
			onFailure: function(){
				addConsoleMsg('Ajax error on getArchiveInfo');
				hideProgress();
			}
		});
	}
	
	// calls an extract action
	function extract(archivename, filename){
		showProgress();
		
		new Ajax.Request('<?php echo $_SERVER['PHP_SELF']; ?>?extract=' + archivename + '&singleFile=' + filename, {
			method: 'get',
			onSuccess: function(transport){
				var response = transport.responseText || "no response text";
				var data = null;
				try {
					data = response.evalJSON();
					if (data == 'true') {
						addConsoleMsg('Extraction ' + archivename + ' successful');
					} else {
						addConsoleMsg('Error while extracting ' + archivename );
					}
				} catch (e) {
					addConsoleMsg(response);
					hideProgress();
					return; // don't go any step further
				}
				
				extracted = true;
				extractedFile = filename;
				hideProgress();
				showAll();
			},
			onFailure: function(){
				addConsoleMsg('Ajax error on extract');
				hideProgress();
			}
		});
	}
	
	// adds a message to the console
	function addConsoleMsg(msg) {
	
		var currentTime = new Date();
		var hours = currentTime.getHours();
		if(hours < 10) { hours = "0" + hours; }
		var minutes = currentTime.getMinutes();
		if(minutes < 10) { minutes = "0" + minutes; }
		var seconds = currentTime.getSeconds();
		if(seconds < 10) { seconds = "0" + seconds; }

		var console = $('console');
		var row = addRow(console);
		addCell(row, 'test');
		var cell = addCell(row, hours + ':' + minutes + ':' + seconds);
		cell.writeAttribute('style', 'width:60px;'); // ad hoc size
		addCell(row, msg);
	}
	
	function showProgress() {
		var div = document.createElement('div');
		Element.extend(div);// without this line,
		div.addClassName('progress'); 
		// the next line causes IE to stop processing the script!
		var img = document.createElement('img');
		Element.extend(img);// without this line, 
		// the next line causes IE to stop processing the script!
		img.writeAttribute('src', '<?php echo $_SERVER['PHP_SELF']; ?>?res=loading');
		div.appendChild(img);
		$('menu').appendChild(div);
	}
	
	function hideProgress() {
		// remove if present
		try { 
			$$('.progress').each(function(elem, index){
				elem.remove();
			});
		} catch (e) {}
	}
	</script>
</head>
<body>
<div id="header">
	<div id="logo">
		<h1><a href="#">Web Archive DePacker</a></h1>
		<h2>A utility for web-developers</h2>
	</div>
	<div id="menu">
		<ul>
			<li><span>Show:</span></li>
			<li><a href="#" id="tabArchive">Archives</a></li>
			<li><a href="#" id="tabAll">All</a></li>
		</ul>
	</div>
</div>
<div id="page">
<div id="content">
	<div id="latest-content" class="content">
		<h1 class="title" id="title"></h1>
		<div id="fileListing" class="entry">
			
		</div>
	</div>
	<div style="clear: both;">&nbsp;</div>
	<div class="hr1">&nbsp;</div>
	<div id="sidebar">
		<ul>
			<li>
				<h2>Work Log</h2>
				<table id="console">
				</table>
			</li>
		</ul>
		<div style="clear: both;">&nbsp;</div>
	</div>
</div>
</div>
<div id="footer">
	<p>Copyright (c) 2008 Claude Gex. All rights reserved. Design by <a href="http://www.nodethirtythree.com/">NodeThirtyThree</a> + <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<script type="text/javascript">
    $('tabArchive').observe('click', showArchives);
    $('tabAll').observe('click', showAll);
    
    // initial, we show the archives
    showArchives();
</script>
</body>
</html>
